home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection Student Program / ADC Tools Sampler CD Disk 3 1999.iso / Metrowerks CodeWarrior / Java Support / Java_Source / IFC_112 / netscape / application / JDK11AirLock.java < prev    next >
Encoding:
Text File  |  1999-05-28  |  3.8 KB  |  123 lines  |  [TEXT/CWIE]

  1. // JDK11AirLock.java
  2. // By Ned Etcode
  3. // Copyright 1995, 1996, 1997 Netscape Communications Corp. All rights reserved.
  4.  
  5. package netscape.application;
  6.  
  7. class JDK11AirLock {
  8.     static boolean lookedForPrintClass = false;
  9.     static Class printClass = null;
  10.     static boolean lookedForMenuShortcut = false;
  11.     static boolean menuShortcutExists = false;
  12.     static boolean lookedForOneOneEvent  = false;
  13.     static boolean hasOneOneEvents     = false;
  14.  
  15.     static boolean hasOneOneEvents() {
  16.       if(lookedForOneOneEvent)
  17.         return hasOneOneEvents;
  18.       else {
  19.         Class c = null;
  20.         try {
  21.           c = Class.forName("java.awt.event.KeyEvent");
  22.         } catch (ClassNotFoundException e) {
  23.         }
  24.         if(c != null)
  25.           hasOneOneEvents = true;
  26.         else
  27.           hasOneOneEvents = false;
  28.         lookedForOneOneEvent = true;
  29.         return hasOneOneEvents;
  30.       }
  31.     }
  32.  
  33.     static void createFoundationPanelListener(FoundationPanel fp) {
  34.       Class c = null;
  35.       FoundationPanelListener listener;
  36.       try {
  37.         c = Class.forName("netscape.application.jdk11compatibility.FoundationPanelListenerImp");
  38.         listener = (FoundationPanelListener) c.newInstance();
  39.         listener.setFoundationPanel(fp);
  40.       } catch (ClassNotFoundException e) {
  41.       } catch (InstantiationException e) {
  42.       } catch (IllegalAccessException e) {
  43.       }
  44.     }
  45.  
  46.     static Clipboard clipboard() {
  47.         Class cClass, jClass;
  48.  
  49.         try {
  50.             cClass = Class.forName("java.awt.datatransfer.Clipboard");
  51.             jClass = Class.forName("netscape.application.jdk11compatibility.JDKClipboard");
  52.             return (Clipboard)jClass.newInstance();
  53.         } catch (ClassNotFoundException e) {
  54.         } catch (InstantiationException e) {
  55.         } catch (IllegalAccessException e) {
  56.         }
  57.         return null;
  58.     }
  59.  
  60.     static boolean setMenuShortcut(MenuItem item, char key) {
  61.         Class cClass, jClass;
  62.         MenuShortcut s;
  63.  
  64.         try {
  65.             cClass = Class.forName("java.awt.MenuShortcut");
  66.             jClass = Class.forName(
  67.                   "netscape.application.jdk11compatibility.JDKMenuShortcut");
  68.             s = (MenuShortcut)jClass.newInstance();
  69.             if (s != null) {
  70.                 s.setMenuShortcut(item.foundationMenuItem, key);
  71.                 return true;
  72.             }
  73.         } catch (ClassNotFoundException e) {
  74.         } catch (InstantiationException e) {
  75.         } catch (IllegalAccessException e) {
  76.         }
  77.         return false;
  78.     }
  79.  
  80.     static boolean menuShortcutExists() {
  81.         Class cClass, jClass;
  82.  
  83.         if (!lookedForMenuShortcut) {
  84.             lookedForMenuShortcut = true;
  85.             try {
  86.                 cClass = Class.forName("java.awt.MenuShortcut");
  87.                 jClass = Class.forName(
  88.                    "netscape.application.jdk11compatibility.JDKMenuShortcut");
  89.                 menuShortcutExists = true;
  90.             } catch (ClassNotFoundException e) {
  91.             }
  92.         }
  93.         return menuShortcutExists;
  94.     }
  95.  
  96.     static boolean isPrintGraphics(java.awt.Graphics g) {
  97.         if (!lookedForPrintClass) {
  98.             lookedForPrintClass = true;
  99.             try {
  100.                 printClass = Class.forName("java.awt.PrintGraphics");
  101.             } catch (ClassNotFoundException e) {
  102.             }
  103.         }
  104.         if (printClass != null) {
  105.             Class gClass;
  106.  
  107.             for (gClass = g.getClass();
  108.                  gClass != null;
  109.                  gClass = gClass.getSuperclass()) {
  110.                 Class interfaces[] = gClass.getInterfaces();
  111.                 int count = interfaces.length;
  112.  
  113.                 while (count-- > 0) {
  114.                     if (interfaces[count].equals(printClass)) {
  115.                         return true;
  116.                     }
  117.                 }
  118.             }
  119.         }
  120.         return false;
  121.     }
  122. }
  123.